home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / rayshade / graphtal.lzh / Graphtal.Amiga / DeviceDriver.h < prev    next >
C/C++ Source or Header  |  1992-11-20  |  3KB  |  98 lines

  1. /*
  2.  * DeviceDriver.h - abstract class definition for device drivers.
  3.  *
  4.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  5.  *                     University of Berne, Switzerland
  6.  * All rights reserved.
  7.  *
  8.  * This software may be freely copied, modified, and redistributed
  9.  * provided that this copyright notice is preserved on all copies.
  10.  *
  11.  * You may not distribute this software, in whole or in part, as part of
  12.  * any commercial product without the express consent of the authors.
  13.  *
  14.  * There is no warranty or other guarantee of fitness of this software
  15.  * for any purpose.  It is provided solely "as is".
  16.  *
  17.  */
  18.  
  19. #ifndef DeviceDriver_H
  20. # define DeviceDriver_H
  21.  
  22. #include "list.h"
  23. #include "table.h"
  24.  
  25. #include "Vector.h"
  26. #include "TransMatrix.h"
  27. #include "BoundingBox.h"
  28. #include "Color.h"
  29. #include "Options.h"
  30.  
  31. /*___________________________________________________________ DeviceDriver
  32.  *
  33.  * Abstract base class for any device driver. The following function
  34.  * must be supplied by a new driver:
  35.  *
  36.  * - void begin() : called before any other graphic commands to
  37.  *                  set up whatever you need.
  38.  * - void end()   : end of interpretation (close the file, ...)
  39.  * - void cylinder(..), cone(..), sphere(..), polygon(..)
  40.  *                : geometric primitives to be supported.
  41.  * - void color(Color) 
  42.  *                : set a new color (better you check if the new
  43.  *                  color is different from the old one!)
  44.  * - void beginMacro(..), endMacro(..), executeMacro(..) 
  45.  *                : member functions for macro support. Within a 
  46.  *                  macro definition you have to store the geometric
  47.  *                  primitives for later use (see WireDevice), or just 
  48.  *                  ignore them (see LineDevice).
  49.  * - void libraryObject(..)
  50.  *                : include a predefined object at the current position
  51.  *                  (it's done in the RayshadeDevice, but for others we 
  52.  *                  would need a general object format).
  53.  */
  54.  
  55. class Polygon;
  56. typedef void* anyPtr;
  57. declareTable(StringTable, rcString, anyPtr);
  58.  
  59. class DeviceDriver
  60. {
  61. public:
  62.   DeviceDriver();
  63.   virtual ~DeviceDriver();
  64.  
  65.   virtual void begin()=0;
  66.   virtual void end(const BoundingBox&)=0;
  67.   virtual void cylinder(const Vector&, const Vector&, real)=0;
  68.   virtual void cone(const Vector&, real, const Vector&, real)=0;
  69.   virtual void sphere(const Vector&, real)=0;
  70.   virtual void polygon(Polygon*)=0;
  71.   virtual void color(const Color&);
  72.   virtual void texture(const rcString&);
  73.   virtual void beginMacro(const rcString&);
  74.   virtual void endMacro();
  75.   virtual void executeMacro(const rcString&, const TransMatrix&);
  76.   virtual void libraryObject(const rcString&, const TransMatrix&);
  77.  
  78.   virtual int addMacroName(const rcString&);
  79.   virtual void addLibraryObjectName(const rcString&);
  80.  
  81.   void setName(const rcString&);
  82.  
  83. protected:
  84.   DeviceDriver(Options*);
  85.  
  86. protected:
  87.   rcString LSystemName;
  88.   Options* theOptions;
  89.  
  90.   long primitives;
  91.   int definingMacro;
  92.   StringTable macroNames;
  93.   StringTable libraryNames;
  94. };
  95.  
  96. #endif // DeviceDriver_H
  97.  
  98.